package cn.dansj.repository;

import com.xxl.job.entity.Connection;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ConnectionRepository extends JpaRepository<Connection, String>, JpaSpecificationExecutor<Connection> {
    @Query(value = "select c.monitor from Connection c where c.sequence = :sequence")
    int getMonitor(@Param("sequence") String sequence);

    @Query(value = "select c from Connection c where c.monitor=1")
    List<Connection> getMonitor();

    Connection getConnectionByName(String name);

    Connection getConnectionBySequence(String sequence);

    List<Connection> getConnectionByDbType(String dbType);

    List<Connection> getConnectionsByDbTypeIn(List<String> dbTypes);
}
